package com.scuec.demo1.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.scuec.demo1.entity.StudentInfo;
import com.scuec.demo1.mapper.StudentMapper;
import com.scuec.demo1.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageInfo<StudentInfo> getStudentInfoPages(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<StudentInfo> studentInfoList = studentMapper.getStudentInfo();
        return new PageInfo<>(studentInfoList);
    }

    @Override
    public PageInfo<StudentInfo> getStudentByPage(Integer pageNum, Integer pageSize) {
        return this.getStudentInfoPages(pageNum, pageSize);  // 复用逻辑
    }

    @Override
    public List<StudentInfo> getStudentInfo() {
        return studentMapper.getStudentInfo();
    }

    @Override
    public StudentInfo getStudentInfoById(Integer id) {
        return studentMapper.getStudentInfoById(id);
    }

    @Override
    public int deleteStudentInfoById(Integer id) {
        return studentMapper.deleteStudentInfoById(id);
    }

    @Override
    public int insertStudentInfo(StudentInfo studentInfo) {
        return studentMapper.insertStudentInfo(studentInfo);
    }

    @Override
    public int updateStudentInfo(StudentInfo studentInfo) {
        return studentMapper.updateStudentInfo(studentInfo);
    }
}